package com.css.modules.lawRepo.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.css.common.utils.PageUtils;
import com.css.common.utils.Query;
import com.css.modules.lawRepo.dao.LawRepoCollectDao;
import com.css.modules.lawRepo.entity.LawRepoCollectEntity;
import com.css.modules.lawRepo.service.LawRepoCollectService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Chen Ao
 * @Date: 2020/2/18/018
 * @Description
 * @Version 1.0
 */
@Service
public class LawRepoCollectServiceImpl extends ServiceImpl<LawRepoCollectDao, LawRepoCollectEntity> implements LawRepoCollectService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String userId = (String)params.get("userId");
        String docId = (String)params.get("docId");

 //       String category = (String)params.get("category");
        IPage<LawRepoCollectEntity> page = this.page(
            new Query<LawRepoCollectEntity>().getPage(params),
                new QueryWrapper<LawRepoCollectEntity>()
                        .eq(StringUtils.isNotBlank(userId),"USER_ID", userId)
                        .eq(StringUtils.isNotBlank(docId),"DOC_ID",docId)
                        .ne("DEL_FLAG", "1")
        );

        return new PageUtils(page);
    }

    @Override
    public void commonUpdateDelFlagBatch(String delFlag, Map<String, Object> mapIds){
        Map<String, Object> map = new HashMap<>(2);
        map.put("list", mapIds.get("ids"));
        map.put("delFlag", delFlag);
        baseMapper.commonUpdateDelFlagBatch(map);

    }

    @Override
    public void commonUpdateDelFlagAll(String delFlag){
        if (StringUtils.isNotBlank(delFlag)) {
            baseMapper.commonUpdateDelFlagAll(delFlag);
        }

    }

}
